package com.wakey.rtcs.web.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.wakey.rtcs.web.mapper.UserMapper;
import com.wakey.rtcs.web.model.User;
import com.wakey.rtcs.web.service.UserService;

@Service
public  class UserServiceImpl implements UserService{

	@Autowired
	private UserMapper userDao;
	
	@Override
	public int addUserObj(User user) {
		user.setPassword("123456");
		return userDao.addUserObj(user);
	}
	
	public List<User> findAll(User user) {
		List<User> userList = userDao.queryAll(user);
		return userList;
	}
	
	public int deleteUser(String[] idArray) {
		return userDao.deleteUser(idArray);
	}
	
	public User getUserById(String userId) {
		// TODO Auto-generated method stub
        User user = userDao.queryById(userId);
        System.out.println(user);
		return user;
	}

	public User getUserByLogin(String userName, String userPwd) {
		// TODO Auto-generated method stub
		User user = userDao.queryByLogin(userName, userPwd);
		return user;
	}

	public int insertUser(String userId, String userName, String userPwd) {
		// TODO Auto-generated method stub
		
		return userDao.insertUser(userId, userName, userPwd);
	}
	
	@Override
	public int addUser(String userName, String userPassword,int userType,String email,String nickName) {
		return userDao.addUser(userName, userPassword,userType,email,nickName);
	}

	@Override
	public void makeOld(Long id) {
		// TODO Auto-generated method stub
		userDao.makeOld(id);
	}

	@Override
	public int updateUser(Long id, String password) {
		// TODO Auto-generated method stub
		return userDao.updateUser(id, password);
	}

	@Override
	public int forgetPassword(String userName, String email, String password) {
		// TODO Auto-generated method stub
		return userDao.forgetPassword(userName,email,password);
	}

	@Override
	public User queryById(Long id) {
		return userDao.queryById(id);
	}

	@Override
	public int editUser(User user) {
		return userDao.editUser(user);
	}


}
